package com.qys.livesMall.event.listener;

import com.qys.livesMall.app.user.event.UserLeveEditEvent;
import com.qys.livesMall.app.user.model.dto.sys.UserLeveEditEventDTO;
import com.qys.livesMall.app.user.service.UserStatisticsInfoService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;


/**
 * 更新用户层级
 */
@Slf4j
@RequiredArgsConstructor
public class UserLeveEditListener {

    private final UserStatisticsInfoService userStatisticsInfoService;
    @Order
    @EventListener(UserLeveEditEvent.class)
    public void updateUserSuperior(UserLeveEditEvent userLeveEditEvent){
        UserLeveEditEventDTO userLeveEditEventDTO= (UserLeveEditEventDTO) userLeveEditEvent.getSource();
        userStatisticsInfoService.updateUserSuperior(userLeveEditEventDTO.getUserId());
    }
}
